package com.yixin.publisher;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@MessageMapping
public class Listener implements ChannelAwareMessageListener {

//        @RabbitListener(queues = "simple.queue")
    @MessageMapping
    public void listenSimpleQueueMessage(String msg) throws InterruptedException {
        System.out.println("spring 消费者接收到消息：【" + msg + "】");
        log.info("shoudao" + msg);
    }

    @Override
    @MessageMapping
    public void onMessage(Message message, Channel channel) throws Exception {
        log.info("收到消息：{}", message.getBody().toString());
    }
}
